package com.xjczjj.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.xjczjj.model.common.Result;
import com.xjczjj.model.qo.LoginQo;
import com.xjczjj.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录退出控制器
 */
@RestController
@RequestMapping("/api")
public class LoginController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 登录
     * @param loginQo
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody LoginQo loginQo) {
        return sysUserService.login(loginQo);
    }

    /**
     * 退出
     * @return
     */
    @GetMapping("/logout")
    public Result logout() {
        StpUtil.logout();
        return Result.ok();
    }
}
